Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects / Object Class Definitions


Application File

An object of class Application File is an application's file on a disk. References to application files must always include a complete description of the file's container. Such references are different from standard AppleScript references
to application objects, which don't always require a complete pathname.

PROPERTIES
An application file has all the properties defined for object class File on page 60: Creator Type, File Type, Locked, Product Version, Stationery, and Version.

Like any other file, an application file also has all the properties defined for object class Item on page 72: Bounds, Comment, Container, Content Space, Creation Date, Disk, Folder, Icon, ID, Information Window, Kind, Label Index, Modification Date, Name, Physical Size, Position, Selected, Size, and Window.

Unlike other files, an application file also has these properties:

minimum partition size
An integer indicating the minimum amount of memory, in bytes, that the application requires to run. This value is equivalent to the value in the box labeled "Minimum size" under "Memory Requirements" in the application file's information window (see "Notes").
Class: Integer
Modifiable: Yes
partition size
An integer indicating the amount of memory, in bytes, that the application is launched with if a block of this size is available. This value is equivalent to the value in the box labeled "Preferred size" under "Memory Requirements" in the application file's information window (see "Notes" on page 40).
Class: Integer
Modifiable: Yes
scriptable
A Boolean value that indicates whether the application is highlevel event aware (true) or not (false)--that is, whether it can respond to the Open, Run, Print, and Quit commands.
Class: Boolean
Modifiable: No
suggested partition size
An integer indicating the amount of memory, in bytes, suggested for running the application. This value is equivalent to the value in the box labeled "Suggested size" under "Memory Requirements" in the application file's information window.
Class: Integer
Modifiable: No
ELEMENT CLASSES
None

COMMANDS HANDLED
Clean Up, Copy, Count, Data Size, Duplicate, Exists, Get, Make, Move, Open, Put Away, Reveal, Select, Sort, Update

DEFAULT VALUE CLASS RETURNED
A reference to a file or, if you use the plural form application files, a list of references.

EXAMPLES
The script that follows checks the Scriptable Text Editor's partition size before opening the application. If the amount of memory available is greater than
the partition size, the script opens the application. If the amount of memory available is less than the partition size, the script displays a dialog box warning the user that the Scriptable Text Editor prefers more memory. This might be useful if a script performs actions requiring more memory than an application's minimum partition size permits.

tell application "Finder"   set x to largest free block
   set y to partition size of ¬
      application file "Scriptable Text Editor" of startup disk
   if x > y then
      open application file "Scriptable Text Editor" of startup disk
   else
      display dialog ¬
         "The Scriptable Text Editor prefers more memory. " & ¬
         "To increase free memory, quit one or more applications."   end if
end tell
This script returns a list of all the application files in a folder:

tell application "Finder"   application files in folder "MyApps" of startup disk
end

--result: {file "Scriptable Text Editor" of folder "MyApps" of startup 
disk, file "Script Editor" of folder "MyApps" of startup disk}
NOTES
The Minimum Partition Size, Partition Size, and Suggested Partition Size are all given in bytes. These values are shown in information windows in kilobytes (K, where 1K = 1024 bytes).

The value of the Partition Size property must be at least as high as the value of the Minimum Partition Size property. If you set the Minimum Partition Size to a value higher than the value of the Partition Size, the Finder also adjusts the Partition Size to match the new Minimum Partition Size. Similarly, if you set the Partition Size to a value lower than the value of the Minimum Partition Size, the Finder also adjusts the Minimum Partition Size to match the new Partition Size.

For example, suppose that the Partition Size and the Minimum Partition Size of the Scriptable Text Editor are both set to 384K. Running this script sets the Minimum Partition size to 460,800 bytes (450K) and at the same time increases the Partition Size to 450K:

tell application "Finder"   set minimum partition size of ¬
      application file "Scriptable Text Editor" of ¬
      application "Finder" to 460800
end tell
If you then run this script, the Finder sets the Partition Size of the Scriptable Text Editor back to 393,216 bytes (384K) and at the same time decreases the Minimum Partition Size to 384K:

tell application "Finder"   set partition size of ¬
      application file "Scriptable Text Editor" of ¬
      application "Finder" to 393216
end tell 

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996